package soap.latherqq.core.manage;

import iqq.im.bean.QQAccount;

import java.io.File;

import org.apache.log4j.Logger;

public class LocalAccountManage{
	private static final Logger log = Logger.getLogger(LocalAccountManage.class);
	private static LocalAccountManage self=null;
	private static final String USER_DATA = "userdata.dat";
	public static synchronized LocalAccountManage self(){
		if(self==null){
			self=new LocalAccountManage();
		}
		return self;
	}
	private LocalAccountManage(){
		
	}

	public void init(){
		
		log.info("本地帐号管理器加载成功!");
	}
	public void destroy(){
		
	}
	public void getLocalAccount(){
		File userDir = new File("user");
		if(!userDir.exists()){
			userDir.mkdirs();
		}
		for(File dir: userDir.listFiles()){
			
			
		}
	}
	public void createUserDir(long uid){
		File userDir = new File("user/"+uid);
		if(!userDir.exists()){
			userDir.mkdirs();
		}
		File face= new File("user/"+uid+"/face");
		if(!face.exists()){
			face.mkdirs();
		}
		File image= new File("user/"+uid+"/image");
		if(!image.exists()){
			image.mkdirs();
		}
	}
	public void saveLoginAccount(){
		new Thread(new Runnable() {
			@Override
			public void run() {
				QQAccount account=ServiceManage.self().getClient().getAccount();
				createUserDir(account.getUin());
			}
		}).start();
	}
}
